begintownscript;

variables;
short bmessage,pcs,seated,leadchar,rctx,rcty;
string custom_m;

body;

beginstate INIT_STATE;
	turn_off_training(1);

	set_incidental_sound(0);
	if(get_flag(83,0) == 4){
		reset_dialog();
		if(party_size() == 1)
			add_dialog_str(0,"There is another portal here.  Presumably, this will take me to Sanctuary.  I'm not that anxious to go though the portal again, but I will do what at this point I have to.",0);
		if(party_size() > 1)
			add_dialog_str(0,"There is another portal here.  Presumably, this will take us to Sanctuary.  We're not that anxious to go though the portal again, but we will do what at this point we have to.",0);
		add_dialog_choice(0,"Unfortunately.");
		bmessage = run_dialog(1);
		set_flag(83,0,5);
	}

	if(get_flag(85,0) >= 10){
		set_terrain(16,12,358);
		set_terrain(16,20,358);
		set_terrain(12,16,358);
		set_terrain(20,16,358);
		set_terrain(13,13,358);
		set_terrain(19,19,358);
		set_terrain(13,19,358);
		set_terrain(19,13,358);
		set_terrain(16,16,137);
		set_terrain(15,16,0);
		set_terrain(17,16,0);
		set_terrain(16,15,0);
		set_terrain(16,17,0);
		force_instant_terrain_redraw();
		reset_dialog();
		if(get_flag(85,0) == 10){
			message_dialog("The portal has become inactive again.  Not that it honestly matters much anyway.","");
			set_flag(85,0,11);
		}
	}

break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;

	if(get_flag(85,0) >= 10)
		end();
	if(is_combat() == TRUE){
		block_entry(1);
		end();
	}
	reset_dialog();
	if(get_highest_skill(42) < 16){
		if(party_size() == 1)
			add_dialog_str(0,"The portal is sitting here, if I'm _brave_ enough to enter...",0);
		if(party_size() > 1)
			add_dialog_str(0,"The portal is sitting here, if we're _brave_ enough to enter...",0);
	}
	else{
		if(party_size() == 1)
			add_dialog_str(0,"The portal is sitting here, waiting for me to step through it.",0);
		if(party_size() > 1)
			add_dialog_str(0,"The portal is sitting here, waiting for us to step through it.",0);
	}
	add_dialog_choice(0,"Don't enter.");
	add_dialog_choice(1,"Enter.");
	bmessage = run_dialog(1);
	if(bmessage == 1){
		block_entry(1);
		end();
	}
	set_total_visibility(1);
	leadchar = 0;
	while(char_ok(leadchar) == FALSE){
		leadchar = (leadchar + 1);
	}
	force_view_center(char_loc_x(leadchar),char_loc_y(leadchar));
	rcty = 0;
	while(rcty <= 31){
		set_terrain(4,rcty,1);
		rcty = (rcty + 1);
	}
	rctx = 0;
	while(rctx <= 31){
		set_terrain(rctx,4,1);
		rctx = (rctx + 1);
	}
	set_terrain(10,3,1);
	set_terrain(11,3,1);
	set_terrain(12,3,1);
	set_terrain(13,3,1);
	set_terrain(3,10,1);
	set_terrain(3,11,1);
	set_terrain(3,12,1);
	set_terrain(3,13,1);
	force_view_center(16,16);
	pcs = 0;
	while(pcs <= 3){
		if(char_ok(pcs) == TRUE){
			put_boom_on_space(char_loc_x(pcs),char_loc_y(pcs), 2,0);
			relocate_character(pcs,1,1);
		}

		pcs = (pcs + 1);
	}
	force_instant_terrain_redraw();
	run_animation_sound(10);
	pause(3);
	move_to_new_town(20,17,11);

break;

